Pandas to_csv乱码

to_csv乱码

self.new_df.to_csv(‘aaaa.csv’, encoding=’utf_8’)之后还是乱码,将utf_8改为utf_8_sig即可

1
self.new_df.to_csv('aaaa.csv',  encoding='utf_8_sig')

read_csv指定分隔符

1
self.df = pd.read_csv(FILE_PATH, sep="|,", encoding = "utf-8")

迭代dataframe

1
2
3
for index, col in self.df.iterrows():
print "当期处理数据条数:", index
current_col_comment = col['列名']